<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./Promise.js"></script>
</head>
<body>
    <script>
        //同步回调执行
        //异步回调执行
        //只能修改一次状态
        //then的返回结果-同步任务
        //then的返回结果-异步任务

        let p = new Promise((resolve, reject) => {
            setTimeout(() => {
                resolve('OOOKKK');
                // reject('error');
            }, 1000);
            // resolve('ok');
            // reject('error');
            // throw 'Error';
        });

        const result = p.then(value => {
            console.log(value);
            return 'love';
        }, reason => {
            console.error(reason);
            return 123;
        });

        console.log(result);
    </script>
</body>
</html>